<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2009 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace common\behavior;



/**
 * 行为扩展：推送项目创建信息
 */
class PushProjectCreatedEventBehavior
{

    /**
     * 推送项目创建信息
     * @param $params
     * @return void
     * @throws \Exception
     */
    public function run(&$params)
    {
        try {
            trace("push project created event to " . request()->getUnionUserId(), 'DEBUG');
            $requestData = [
                'param' => [
                    'filter' => [
                        'id' => request()->getUnionUserId(),
                    ],
                    'data' => [
                        'event_key' => 'project_created',
                        'event_data' => $params['data'],
                    ]
                ]
            ];
            teamones_request('teamones-im', 'oauth/send_data_to_user_channel', $requestData);
        } catch (\Throwable $e) {
            trace(format_exception_info($e), 'ERR');
        }
    }

}
